<?php
include_once 'module/controls.php';
include_once 'model/page/process.php';
include_once 'model/user/user_create.php';
include_once 'model/board/process.php';
$board_page = new pages();
$user = new users();
$board = new boards();
$c = new controls();

$fillByName = $user->FillOneByName($_SESSION);
$result = $board_page->FillAll();
$numberTrash = $board_page->FillAllTrash();
$numberDrafts = $board_page->FillAllDrafts();
$level_decode = json_decode($fillByName["level"], true);
$fillAll = $board->FillAll();
?>
<div id="content">
    <h2 class="jquery_tab_title"><?php echo $phrase["manager_page"] ?></h2>
    <?php if ($level_decode["admin"] != "" || $level_decode["create"] != "") { ?>
        <span class="bglink"><a class="link" href="<?= $url["home"] ?>/menu/pagecreate/t/2"><?php echo $phrase["page_create"] ?></a></span>
        <?php if(mysql_num_rows($numberDrafts) > 0) : ?>
            <span class="bglinkleft"><a class="link" href="<?= $url["home"] ?>/menu/pagerecycle/t/2"><?php echo $phrase["bannhap"] ?></a></span>
        <?php endif; ?>
        <?php if(mysql_num_rows($numberTrash) > 0) : ?>
            <span class="bglinkleft"><a class="link" href="<?= $url["home"] ?>/menu/pagetrash/t/2"><?php echo $phrase["trash"] ?></a></span>
        <?php endif; ?>
    <?php } ?>
    <div style="clear: both;" ></div>
    <span class="combobox-right">
        <select name="board_name" id="board_name" >
            <?php
            while ($rows = mysql_fetch_array($fillAll)) {
                ?>
                <option value="<?= $rows["board_id"] ?>"><?= $rows["board_name"] ?></option>
            <?php } ?>
        </select>
    </span>
    <div id="conten1" style="padding-top:10px"></div>
</div>
<script type="text/javascript">
    $(document).ready(function() {
        loadData($("#board_name").val());
        
        $("#board_name").change(function(){
		var id=$(this).val();
		loadData(id);
	});
    });
    
    function loadData(id){
        var dataString = 'id='+ id + '& username=<?php echo $_SESSION["username"] ?>';
        $.ajax({
                type: "POST",
                url: "<?php echo $url["home"] ?>/model/page/board_page.php",
                data: dataString,
                cache: false,
                success: function(html){
                    $("#conten1").html(html);
                } 
        });
    }
</script>